var setInnerHTML = function (el, htmlCode) {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
        htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
        htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
                                    '<script$1 defer="true">');
        el.innerHTML = htmlCode;
        el.removeChild(el.firstChild);
    }
    else {
        var el_next = el.nextSibling;
        var el_parent = el.parentNode;
        el_parent.removeChild(el);
        el.innerHTML = htmlCode;
        if (el_next) {
            el_parent.insertBefore(el, el_next)
        } else {
            el_parent.appendChild(el);
        }
    }
}
document.write = function() {
    var body = document.getElementsByTagName('body')[0];
    for (var i = 0; i < arguments.length; i++) {
        argument = arguments[i];
        if (typeof argument == 'string') {
            var el = body.appendChild(document.createElement('div'));
            setInnerHTML(el, argument)
        }
    }
}
function $(e){
    return top.document.getElementById(e);
}
function checkEscape(e) {
	if(!e) e = event;
	if(e.keyCode == 27) return false;
}
function MyStatus(){
    var msg = "Web Streaming";
	for(var i=1;i<=iStatus;i++){
		msg = msg + ".";
	}
	if(iStatus >= 3){
	  iStatus = 0;
	}
	else{
	  iStatus++;
	}
	window.status = msg;
	if(!iTrue){
		setInterval('MyStatus();',1000);
		iTrue = true;
	}
}
function iEvent(even,func){
	if(typeof window.addEventListener != "undefined") {
		window.addEventListener(even, func, false);
	}
	else if(typeof document.addEventListener != "undefined") {
		document.addEventListener(even, func, false);
	}
	else if(typeof window.attachEvent != "undefined") {
		window.attachEvent("on" + even, func);
	}
}
var ie = function(){
	setInnerHTML($("_MyFrame"),'<iframe src="javascript:top.frame" style="display:none"></iframe>');
}
var ff = function() {
	setInnerHTML($("_MyFrame"),'<iframe src="'+url+'" style="display:none"></iframe>');
/*
	//var ff1 = false;
	var ff2 = false;
	//ff1 = document.createElement('iframe');
	//ff1.style.display = "none";
	//ff1.id = 'comet';
	ff2 = document.createElement('iframe');
	ff2.style.display = "none";
	ff2.src = url;
	//document.body.appendChild(ff1);
	document.body.appendChild(ff2);
*/
}
////////
var url = 'webstream.cgi';
var frame = '<frameset rows="50%,50%">';
frame += '<frame id="f1" src="'+url+'">';
frame += '<frame id="f2" src="javascript:top.url">';
frame += '</frameset>';
if(navigator.appVersion.indexOf("MSIE") != -1){
	iEvent("load",ie);
}
else{
	iEvent("load",ff);
}
var iStatus = 0;
var iTrue= false;
MyStatus();
//document.onkeydown = checkEscape;
//document.onkeypress = checkEscape;
////////